<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
namespace Admin\Service;

class ImageService{
	
    /**
     * 保存图片信息
     * @return unknown
     */
    public function save($image){
        //step-1: 查询是否存在
        $Model = D('Image');
        
        $imageExist = $Model->where(array("url"=>$image['url']))->find();
        if(!empty($imageExist)) {
            return $imageExist['id'];
        }
        //step-2: 设置默认参数
        $image['creator'] = empty($image['creator']) ? 2 : $image['creator'];
        
        //step-3: 保存
        return $Model->add($image);
        
	}
	
	
}